﻿<phone:PhoneApplicationPage 
	x:Class="VkontakteMangoClient.MessageConversation"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
	xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:ViewModel="clr-namespace:VkontakteViewModel;assembly=VkontakteViewModel"
	xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
	xmlns:Helpers="clr-namespace:VkontakteMangoClient.Helpers" FontFamily="{StaticResource PhoneFontFamilyNormal}"
	FontSize="{StaticResource PhoneFontSizeNormal}"
	Foreground="{StaticResource PhoneForegroundBrush}"
	SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
	mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
	shell:SystemTray.IsVisible="True"
	toolkit:TiltEffect.IsTiltEnabled="True">

	<toolkit:TransitionService.NavigationInTransition>
		<toolkit:NavigationInTransition>
			<toolkit:NavigationInTransition.Backward>
				<toolkit:TurnstileTransition Mode="BackwardIn"/>
			</toolkit:NavigationInTransition.Backward>
			<toolkit:NavigationInTransition.Forward>
				<toolkit:TurnstileTransition Mode="ForwardIn"/>
			</toolkit:NavigationInTransition.Forward>
		</toolkit:NavigationInTransition>
	</toolkit:TransitionService.NavigationInTransition>
	<toolkit:TransitionService.NavigationOutTransition>
		<toolkit:NavigationOutTransition>
			<toolkit:NavigationOutTransition.Backward>
				<toolkit:TurnstileTransition Mode="BackwardOut"/>
			</toolkit:NavigationOutTransition.Backward>
			<toolkit:NavigationOutTransition.Forward>
				<toolkit:TurnstileTransition Mode="ForwardOut"/>
			</toolkit:NavigationOutTransition.Forward>
		</toolkit:NavigationOutTransition>
	</toolkit:TransitionService.NavigationOutTransition>
	
	<phone:PhoneApplicationPage.Resources>
		<ViewModel:MessageConversationPageViewModel x:Name="MessageConversationViewModel" />
	</phone:PhoneApplicationPage.Resources>
	<phone:PhoneApplicationPage.DataContext>
		<Binding Source="{StaticResource MessageConversationViewModel}" />
	</phone:PhoneApplicationPage.DataContext>

	<!--LayoutRoot is the root grid where all page content is placed-->
	<Grid x:Name="LayoutRoot" Background="Transparent">
		<Grid x:Name="ContentPanel" Margin="12,0,12,0">
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto" />
				<RowDefinition Height="*" />
				<RowDefinition Height="Auto" />
			</Grid.RowDefinitions>
			
			<TextBlock Grid.Row="0" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding UserViewModel.FullNameAndNickName, Mode=OneWay}" VerticalAlignment="Top" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
			

			<ListBox x:Name="ListBoxMessages" Grid.Row="1" ItemsSource="{Binding Messages}" 
					 HorizontalAlignment="Left" 
					 SelectionChanged="ListBoxMessages_OnSelectionChanged">
				<ListBox.ItemTemplate>
					<DataTemplate>
						<Grid Margin="0" Width="{Binding ScreenWidth,Source={StaticResource MessageConversationViewModel}}">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto" />
								<ColumnDefinition Width="*" />
							</Grid.ColumnDefinitions>
							<StackPanel>
								<Image Source="{Binding User.PhotoMedium}" Margin="0 12 0 0" Height="100" Width="100" Stretch="UniformToFill" VerticalAlignment="Top" />
								<TextBlock Text="{Binding User.LastName}" HorizontalAlignment="Center" />
								<TextBlock Text="{Binding User.FirstName}" HorizontalAlignment="Center" />
								<TextBlock Text="{Binding User.Nickname}" HorizontalAlignment="Center" />
							</StackPanel>
							<StackPanel Grid.Column="1"  d:LayoutOverrides="Margin">
								<TextBlock Text="{Binding Title, Mode=OneWay}" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
								<TextBlock Text="{Binding Date, Mode=OneWay}" Style="{StaticResource PhoneTextSubtleStyle}"/>
								<TextBlock Text="{Binding Body, Mode=OneWay}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0,0,0" FontWeight="{Binding ReadStateFontWeight}"/>
							</StackPanel>
						</Grid>
					</DataTemplate>
				</ListBox.ItemTemplate>
				
			</ListBox>
			<Grid Grid.Row="2">
				<toolkit:PhoneTextBox Text="{Binding NewMessageText, Mode=TwoWay}" Hint="type a text message" Helpers:TextBoxBindingHelper.UpdateSourceOnChange="True" />
			</Grid>
		</Grid>
	</Grid>
	
	
	<!--Sample code showing usage of ApplicationBar-->
	<phone:PhoneApplicationPage.ApplicationBar>
		<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
			<shell:ApplicationBarIconButton IconUri="/Images/dark/appbar.sendmessage.rest.png" Text="Send" Click="ApplicationBarIconButtonAddMessage_OnClick" x:Name="SendMessageButton" IsEnabled="False" />
			<shell:ApplicationBarIconButton IconUri="/Images/home.png" Text="Home" Click="ApplicationBarIconButtonHome_OnClick"/>
			<shell:ApplicationBarIconButton IconUri="/Images/dark/appbar.favs.addto.rest.png" Text="Pin to start" Click="ApplicationBarMenuItemPinToStart_Click"/>
			<shell:ApplicationBarIconButton IconUri="/Images/dark/appbar.refresh.rest.png" Text="Refresh" Click="ApplicationBarIconButton_OnClick"/>
			<shell:ApplicationBar.MenuItems>
				<shell:ApplicationBarMenuItem Text="Pin to start" Click="ApplicationBarMenuItemPinToStart_Click"/>
			</shell:ApplicationBar.MenuItems>
		</shell:ApplicationBar>
	</phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
